package com.lin.csdn.utils;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import java.util.List;

public class BlogJsonUtil {
//用于blog格式的JsonArray的输出
    public JSONArray blogJson(List<Object> data){
        JSONArray array=new JSONArray();
        for(int i=0;i<data.size();i++){
            JSONObject object=new JSONObject();
            object.put("id",data.get(i));
            i++;
            object.put("title", data.get(i));
            i++;
            object.put("description",data.get(i));
            i++;
            object.put("praise",data.get(i));
            i++;
            object.put("date",data.get(i));
            i++;
            object.put("username",data.get(i));
            array.put(object);
        }
        return array;
    }
}
